code repo connnect test
[shlib.git] / doc / design-doc / 3.3.catalog-tree structure data orgnize.txt
blobd2108553d9af5fddbc04fb5996819978714f8711
1 doc of shlib
3   Copyright (C) 2022- Free Software Foundation, Inc.
5   Copying and distribution of this file, with or without modification,
6   are permitted in any medium without royalty provided the copyright
7   notice and this notice are preserved.
9 The following contributions warranted legal paper exchanges with the
10 Free Software Foundation.
13 [tmp]
14 @ trimple name string.
15 # use attr/attr-var instead of var, because it will mix with the variable in src code.
16 # use node-type instead of type. use file-type instead of type.
19 # guide-catalog
20 ===============
21  1. introduction
22  2. example
23  3. concept
24  4. attr-var
25  5. operation
26  6. node processing
27  6.1. format paramter for strnode
28  6.2. strnode and catanode/dirnode
29  7. catalog and src code
30  7.1. create or update src code by design file
31  7.2. create or syncronize back to design file by src code
32  8. itemnode
33  8.1 node type
34  8.2 var2cata()
35  8.3 item2var()
36  9. conclusion
40 # 1.introduction
41 ================
42     catalog is a syntax of text file developed by my self. at first, i'm writing program module design draft by tab indented text, 
43 to express 'sub-' structure between two items. and i create source file dir accroding this text guide doc.
44     i copy one source code file to create a new source code file, and modify module name of source file frequently. i have an idea 
45 that, the framework of source code file can be generated by the draft doc file.
46     so, catalog file is borned.
47     and catalog file also can be used for other purpose:
49 @ test code generation like source code generation.
50 @ menu description for displaying of program, neither console menu, nor gui 
51   menu.
52 @ use it as a config file in soft pkg by config menu.
54     usually, it is used for doc wrting, and generate other docs or source code.
57 # 2.example
58 ===========
61 # 1. paramters for global catalog file
63 [param]
65 # public paramter define include
66 minc catalog.imi
68 node_seperater="."
70 # general syntax defination.
71 node_gen_fmt="@(rptchar ' ')<@{ITEM_VAR[0]}>.[@{ITEM_VAR[1]}].@{ITEM_VAR[2]}.\"@{ITEM_VAR[3]}\""
72 node_dispose_syntax="([ \t]+)<([0-9.<>])>\.[([a-zA-Z0-9_]+)]\."([a-zA-Z0-9-_ ]+)""
74 # normally, it is no need to set this variable. use node info instead.
75 dirnode_gen_fmt="@(rptchar ' ')<@{ITEM_VAR[0]}>.[@{ITEM_VAR[1]}].@{ITEM_VAR[2]}.\"@{ITEM_VAR[3]}\""
76 dirnode_dispose_syntax="([ \t]+)<([0-9.<>])>\.[([a-zA-Z0-9_]+)]\."([a-zA-Z0-9-_ ]+)""
78 # normally, it is no need to set this variable. use node info instead.
79 itemnode_gen_fmt="@(rptchar ' ')<@{ITEM_VAR[0]}>.[@{ITEM_VAR[1]}].@{ITEM_VAR[2]}.\"@{ITEM_VAR[3]}\""
80 itemnode_dispose_syntax="([ \t]+)<([0-9.<>])>\.[([a-zA-Z0-9_]+)]\."([a-zA-Z0-9-_ ]+)""
82 # it's defined by codegen
83 contnode_gen_fmt="@(rptchar ' ')<@{ITEM_VAR[0]}>.[@{ITEM_VAR[1]}].@{ITEM_VAR[2]}.\"@{ITEM_VAR[3]}\""
84 contnode_dispose_syntax="([ \t]+)<([0-9.<>])>\.[([a-zA-Z0-9_]+)]\."([a-zA-Z0-9-_ ]+)""
88 # 2. catalog for dir structure
90 [catalog-dir]
91 <1>.[dir].FirstModuleSet."first module set"
92     <1>.[item].TestModule."program module for testing"
93     # means it's catalog id is followed from sbove.
94     # it's usefull when i copy text to other place.
95     <->.[item].NextTestModule."the other test module"
96 <->.[dir].SecondModuleSet."second module set"
97     <1>.[item].ThirdTestModule."the third test module"
100 # 3. catalog for item content
102 [catalog-content]
103 <->.[item].TestModule."program module for testing"
104     <1>.[var].TestVar."test var for this module"
105     <->.[func].TestFunc."test function for this module"
106     
107 <->.[item].NextTestModule."the other test module"
108     <1>.[var].TestVar2."test var2 for this module"
109     <->.[func].TestFunc2."test function2 for this module"
110     
111 <->.[item].ThirdTestModule."the third test module"
112     <1>.[var].TestVar3."test var3 for this module"
113     <->.[func].TestFunc3."test function3 for this module"
115     
116     there are three part of a catalog file.
117 @ paramter, used for catalog dispose. any paramter is setted by cmd line also can be setted in this section.
118 @ catalog-dir, it describe a dir structure for dir/file generating.
119 @ catalog-content, it is usually used for generate file content. if it is put on catalog-dir, the catalog information is not very clear. it likes a book, catalog-dir is catalog, and here is content.
120     
121     the id of item is '-'. it will be fill with correct id increased from lastest one.
124 # 3.concept
125 ===========
126          concept & words & short-name & short name combination.
127          
128 [concept]
129 @ the feature of catalog: it include catalog, dst-dir, and filecont. and normally is used to generate files automatically.
130 @ catalog: it is a tree structured txt file, and is used to wrting note or setting paramter. it is consisted by catanode.
131 @ dst-dir: the things outputed on file system accrodding catalog data. it is consisted by dirnode and itemnode.
132 @ filecont: file content generated by catalog data and file templete. it is consisted by contnode.
133 @ translation: catalog is a src design file, and dst-dir is the output thing. generating operation between catalog and dst-dir, 
134 is translate operation. the higher level is catalog to dst-dir/filecont, the lower level is catanode to dirnode/itemnode/contnode.
135 |- catalog <=> varnode <=> dstdir/filecont
136 |- catanode <=> varnode <=> dirnode/itemnode/contnode(cata2dir/dir2cata/cata2item/item2cata, cata2cont/cont2cata)
137     finally, the translate operation is between varnode and other node.
138 catanode/dirnode/itemnode/contnode <=> varnode(cata2var/var2cata, dir2var/var2dir/item2var/var2item, cont2var/var2cont)
140 @ catalog(cata):
141 # catanode(cnode): node in catalog. it is a sting.
142 # dircata: dir catalog string in catalog.
143 # itemcata: item catalog string in catalog.
144 # contentcata(contcata): content catalog string in catalog.
146 @ var: attribute variable.
147 # varnode(vnode): attr-var used to describe a node.
148 # varlist: it is also a attribute variable, that consisted by varnode.
150 @ outputnode(onode): it is the node entity that varnode generated.
151 # dirnode(dnode): dir cata in file system.
152 # itemnode(inode): item cata file in file system.
153 # contentnode(contnode): content cata data in item file.
155 @ node: a node is strnode + physical-feature. the expration method of a node, is the strnode. so, the translating operation
156 between varnode and other node, is also the translating operation between varnode and strnode. strsyntax.shlib implement this
157 feature.
158 @ field: the string consist of a strnode.
159 @ strnode: a formatted string consisted by some string data.
160 strnode <=> varnode(str2var/var2str)
161 @ varnode: it is an attr-var to describe a node. the attr content is the string data corresponding to a actual node.
162 @ dirnode: dir in dst-dir. it is consisted by dirnode * N + itemnode * N.
163 @ itemnode: an item is consisted by a set of file. it is consisted by strnode * N.
164 @ contnode: the output file is a language src file, contnode is one of the language feature in src code.
165 @ catanode: one line formatted string in catalog. it the general name of dircata/itemcata/contcata
167 @ dircata: it is a dir/file structure of catalog,
168 @ itemcata: it is the item node description.
169 @ contcata: it is the content node in a file.
171 @ var, variables that store data for one node line.
172 @ list, describe variables under a node, or list all node in catalog file.
173 @ varlist, 
175 @ dircata, dir desc node in catalog. generally, it is just named as catanode.
176 @ dirnode, one dir or one file on filesystem.
177 @ dirvar, a set of var to express one dir/file. generally, it is just named as varnode.
178 @ dirlist, a set of array, to record dir/file in dir without file content node, dirlist=dirvar*N. generally, it is just named 
179 as varlist.
182 # 4.attr-var
183 ============
184         attr-var is the short name of attribute variable.
185         there no structured variable in shell environment. attr-var is used to orgnize variable like a structure, so that developers
186 can use the attr-var name as a paramter, it carried lots of variable information. 
187         attr-var describe a node, and there are many node in catalog file or filesystem or file-content. put those attr-var translated
188 from strnode together as a integerated attr-var, it is called as 'varlist', it's the list of attr-var. the operation on catalog
189 or filesystem-dir or file-content, can be moved on varlist. it's the middle thing in translation.
190         see the chapter of 'attr-var', and get the detail usage.
193 # 5.operation
194 =============
195     the main function of catalog is generating files automatically. generally, files is program src code file, or testcase unit.
196         catalog file is the source of codegen. it generate dir & files(item) on filesystem, and generated file content by templete.
197         
198              / dir & files(item)
199 catalog <=> |
200              \ content
202         uses function catalog2dstdir()/dstdir2catalog(). those two function is mapped to program paramter of "dst-dir generating 
203 or updating" and "generating or syncronize back to catalog".
205         when catalog file is used to generate or update src-code, the translating step is like below.
206 catalog => dircata/itemcata => varnode => dir-varlist => varnode => dirnode/itemnode => dst-dir
207                                =================================
208            ===========================                   ===========================
209 =======---------------------------------------------------------------------------------=======
210 catalog => contcata => varnode => cont-varlist => varnode => contnode => filecont
211                        ==================================
212            ===================                    ===================
213 =======------------------------------------------------------------------=========
215     when dir/files is used to generate or syncronize back to catalog file, the step is like below.
216 dst-dir => dirnode/itemnode => varnode => dir-varlist => varnode => dircata/itemcata => catalog
217                                =================================
218            ===========================                   ===========================
219 =======---------------------------------------------------------------------------------=======
220 filecont => contnode => varnode => cont-varlist => varnode => contcata => catalog
221                          ==================================
222              ===================                    ===================
223 =========------------------------------------------------------------------=======
225         "-" connect two part of translation. use function dstdir2catalog()/catalog2dstdir()/filecont2catalog()/catalog2filecont().
226         it's the interface for program running. it will invoke some 'foreach' function to trig node data translating.
228     the operation in step is consisted by two part. and itemnode is the middle thing in those two step.
229         one step is catalog structure processing. it is relatived to physical dir/file on filesystem. it's the same part of any file 
230 generating operation.
231         the other step is content processing. different item file-type uses different templete file.
233         catalog operation is equal to node operation. because node is the basical unit, either in catalog file, or in dst-dir on 
234 filesystem.
235         
236             / dircata  \      / dirvar   \       / dirnode   <=> dir on
237                                                                                                                                  filesystem
238 catanode =>| itemcata   | <=> | itemvar   | <=> | itemnode   <=> dir/files on 
239                                                                                                                                  filesystem
240             \ contcata /      \ contvar  /       \ contnode  <=> content in 
241                                                                                                                                  file
242         
243         dircata/itemcata/contcata in catalog file is nearly the same. so, combine them as catanode. it is also the same on 
244 dirvar/itemvar/contvar, and combine them as varnode. the process procedure is below.
246 catanode <=>           varnode      <=>    dirnode/itemnode/contnode
247       cata2var()     var2dir()/var2item()/var2cont()
248       var2cata()     dir2var()/item2var()/cont2var()
250         use function :
252 @ cata2var()/var2cata(), 
253 @ dir2var()/var2dir()/item2var()/var2item(), 
254 @ cont2var()/var2cont().
256     all those thing is node, and dirnode/itemnode/contnode is very similar with catanode, they are a string with some particular
257 feature. actually, the general processing procedure is string processing with varnode. i give it a name called strnode.
258         dirnode = strnode + dir, itemnode = ( strnode + file ) * N.
259         now, the traslation between varnode and other node, it looks like this:
261 strnode <=> varnode.
263         use function str2var()/var2str().
266 # 6.node processing
267 ===================
268         node is the basic unit of catalog and dst-dir, strnode is the general part of them. so, every node operation with the 
269 corresponding feature, dir/file on filesystem, or string processing in file. and the general operation.
271 catanode <=> varnode <=> dirnode/itemnode/contnode
272 strnode <=> varnode.
274         ignor the particular operation, we focus on translation between strnode and varnode. the function we need to care about is 
275 str2var()/var2str().
276         those two function translat a formatted string, to a attribute variable. the acual processing procedure reference from chapter 
277 of 'strnode and catanode/dirnode'.
279         contnode is different from dirnode and itemnode, it is used for templete feature. reference this feature from the chapter about
280 codegen.
282         the node of '<catalog-bottom>' is used to exit from catalog file disposing. the whole catalog dispose is based on imi file
283 dispose. this tag break catalog dispose, and back to imi file dispose.
284         it is used to process two stage of catalog content. put a tag at the end of dir catalog section, it trig a catalog process 
285 function, and generate dst-dir. and invoke file content function in content catalog section every item node.
288 # 6.1.format paramter for strnode
289 =================================
290         in catalog file, catanode is a one-line-string with a format. and other thing like dirnode/itemnode/contnode is also a formatted
291 string.
292         the purpose of catalog file is the note for code design, dirnode/itemnode is a normal file name string seperated by '.', and 
293 contnode is the grammar element in a program language. so, the string format is designed accrodding to it's using purpose.
294         in a catalog file, we write doc for program module, and catagory them by dir structure. a catanode is a record in database, 
295 it is consisted by some data-field it needed. see the example above. greb a piece of txt as an example:
297 <->.[item].TestModule."program module for testing"
298 <cataid>.[node-type].name."desc"
300         the format of a catanode is consisted by cataid/node-type/name/desc. function str2var() and var2str() is used to translate 
301 between them. attr-var include variable cataid/node-type/name/desc.
302         it this format fixed? or how to describe this format?
303         it defined some paramter in some imi file like below.
305 # catalog node string
306 [catanode]
307 attr node_fmt='<@{0}> [@{1}] @{2} "@{3}"'
308 attr var_rege="([a-zA-Z0-9_ ]*)"
309 #attr regexpr='<([a-zA-Z0-9_ ]*)> [([a-zA-Z0-9_ ]*)] ([a-zA-Z0-9_ ]*) "([a-zA-Z0-9_ ]*)"'
310 attr sepchar='.'
311 attr attr_wrap=( "none" "wrap1" "wrap2" "wrap3" "<" "<<" "<<<" "[" '\"" "[" )
312 attr attr_idx=( NID NTYPE NNAME NDESC )
313 attr nid_idx= 0
315         string generate by attr-var is very easy, it invoke strfmt() to generate string by node_fmt attribute and attr-var.
316         there are 3 type of method to dispose a strnode to attr-var.
317 @ using one char to seperate data-field, and give a wrap of data-field like "<>" or "[]". it is a easy way to implement string
318 dispose.
319 @ using reg-expr string to describe strnode format, and use =~ operator in shell with a reg-expr matching.
320 @ node_fmt is defined to generate strnode, and use this format to dispose strnode. the paramter var_rege is define for variable
321 in node_fmt. replace var_rege to variable, we get the reg-expr string like paramter 'regexpr'. the match result is stored in 
322 variable defined in node_fmt. it's the easist way to use strnode fmt, but cost a bit more cpu usage, but it is easy to use, and
323 can be defined smartfull.
325         those three method is associated to var_rege/regexpr/sepchar. so, if the paramter is defined, using the method it takes.
327         other side, the strnode format paramter for dirnode/itemnode/contnode is also defined like catanode. the actual implement
328 code of those tree method is ignored in this document, look at the src file in shlib.
331 # 6.2.strnode and catanode/dirnode
332 ==================================
334 catalog => dircata/itemcata => varnode => dir-varlist => varnode => dirnode/itemnode => dst-dir
335            ===========================                   ===========================
336 catalog => contcata => varnode => cont-varlist => varnode => contnode => filecont
337            ===================                    ===================
339 dst-dir => dirnode/itemnode => varnode => dir-varlist => varnode => dircata/itemcata => catalog
340            ===========================                   ===========================
341 filecont => contnode => varnode => cont-varlist => varnode => contcata => catalog
342             ===================                    ===================
344         catanode, dirnode, itemnode, is input or output node. and varnode is a media for translation between other node.
345         in chapter 'operation', we absolute general node as a strnode, which is a formatted string, and use str2var()/var2str() for 
346 translation. in this chapter, we discuss the implementation of str2var()/var2str(). 
348         translation between strnode and varnode:
349 + use strfmt to generate string.
350 + use seperated char to divide string into an array. uae idx to attr, store in corresponding attr var.
351 + use regexpr, output matching string.
352 + use node_fmt paramter that same as the one for strfmt. fill var regexpr string into node_fmt, it's the same as regexpr.
355 # 7.catalog and src code
356 ========================
357         the main purpose of catalog file is generating src code framework. there are several operations:
358 @ generate new src code framework by catalog file.
359 @ update changes on existing src code, which is generated by codegen.
360 @ generate new catalog file by src code dir.
361 @ syncronize src code back to catalog file.
363         tihs chapter is discuss around those feature.
366 # 7.1.create or update src code by design file
367 ==============================================
368             / dir & files(item)
369 catalog => |
370             \ content
372 catalog => dircata/itemcata => varnode => dir-varlist => varnode => dirnode/itemnode => dst-dir
373 =======---------------------------------------------------------------------------------=======
374 catalog => contcata => varnode => cont-varlist => varnode => contnode => filecont
375 =======------------------------------------------------------------------========
377         in this chapter, we focus the point at translation between catalog and dst-dir/filecont. the function catalog2dstdir(), 
378 catalog2filecont() take this work as a interface for program feature implement. and the lower level function, translation between 
379 catanode and others, is introduced above.
380         here we talk about the thing, what's the implementation in the function like dstdir2catalog().
381         file content is implemented by temeplete feature in shlib, it uses varlist to generate src file content. we talk it in an other
382 chapter.
383         
384         there two type of method to generate dst-dir by catalog file.
385 @ ergodic the catalog file, and dispose catanode one by one in catalog file, and invoke translating function every catanode disposeed.
386 @ ergodic the catalog file, and dispose catanode to a varlist. ergodic varlist, and invoke translating function every varnode.
388         it looks the same, and varlist is redundent. but think about the condition when the dst-dir is exist. the generating operation
389 is changed with update operation. in order to compactive with new create operatioin, we call this generating. it include new 
390 creatioin and exist update.
391         there are also N method to process generating operation.
392 @ ergodic catalog, and dispose strnode to varlist. ergodic itemnode in dst-dir one by one without varlist generating, compare varnode with the one in catalog varlist.
393 + node is the same, skip operation.
394 + node is different, rename dirnode/itemnode by catalog varnode.
395 + node is not exist in catalog varlist, move the dirnode/itemnode to trash.
396         delete varnode in catalog varlist after comparation. at the end of dst-dir ergodic, ergodic catalog varlist again, and create 
397 dirnode/itemnode.
398 @ ergodic catalog & dst-dir, and dispose strnode to varlist. ergodic dst-dir varlist, compare varnode with the other one in 
399 catalog varlist.
400 + node is the same, skip operation.
401 + node is different, rename dirnode/itemnode by catalog varnode.
402 + node is not exist in catalog varlist, move the dirnode/itemnode to trash.
403         delete varnode in dst-dir varlist after comparation. at the end of varlist ergodic, ergodic dst-dir varlist again, and create 
404 new dirnode/itemnode.
405 @ ergodic catalog & dst-dir, and dispose strnode to varlist. ergodic catalog varlist, compare varnode with the other one in 
406 dst-dir varlist.
407 + node is the same, skip operation.
408 + node is different, rename dirnode/itemnode by catalog varnode.
409 + node is not exist in dst-dir varlist, create dirnode/itemnode.
410         delete varnode in dst-dir varlist after comparation. at the end of varlist ergodic, ergodic dst-dir varlist again, and move 
411 the dirnode/itemnode to trash.
412 @ ergodic catalog, and dispose strnode to varlist. ergodic current dir in dst-dir without varlist generating, compare varnode with the one in catalog varlist.
413 + node is the same, skip operation.
414 + node is different, rename dirnode/itemnode by catalog varnode.
415 + node is not exist in catalog varlist, move the dirnode/itemnode to trash.
416         delete varnode in catalog varlist after comparation. at the end of current dir ergodic, ergodic catalog varlist, and move 
417 the dirnode/itemnode to trash.
418 @ ergodic catalog, and dispose strnode to varlist. ergodic current dir in dst-dir with varlist. ergodic catalog varlist 
419 continously, compare catalog varnode with the one in current dir varlist.
420 + node is the same, skip operation.
421 + node is different, rename dirnode/itemnode by catalog varnode.
422 + node is not exist in current dir varlist, create the dirnode/itemnode.
423         delete varnode in current dir varlist after comparation. at the end of current dir ergodic, ergodic current dir varlist again, 
424 and move the dirnode/itemnode to trash.
426         here, we use catalog varlist ergodic instead of catalog ergodic, for exist updating condition.
427         and we can ergodic whole dst-dir varlist, or ergodic dst-dir one by one. itemnode can be consisted by many files. getting the 
428 itemnode varlist is based on current file listing. the itemnode list under a dir is generated at the same time. so, it can't ergodic 
429 itemnode just one by one actually. the first method is not the executable one.
430         the second and third method generate whole dst-dir varlist. it cost more memory resource rather than the last one.
431         
432         itemnode is a particular thing, it can be consisted by many files. the node dispose procedure is discussed in later.
433         catalog2filecont() output src code content by templete, reference from chapter about codegen, or templete.
436 # 7.2.create or syncronize back to design file by src code
437 ==========================================================
438             / dir & files(item)
439 catalog <= |
440             \ content
442 dst-dir => dirnode/itemnode => varnode => dir-varlist => varnode => dircata/itemcata => catalog
443            ===========================                   ===========================
444 filecont => contnode => varnode => cont-varlist => varnode => contcata => catalog
445 =========------------------------------------------------------------------=======
447         the procedure is similar with design file to src code. we need to care about this thing:
448 @ itemnode list is generated together in a dir, not one by one.
449 @ dest catalog node is existing when generate node by dirnode/itemnode.
450 @ the sequence of catanode in catalog file, especially when the catalog file is existing.
451 @ some dst-dir node contains cataid, but the other one maybe not contained.
452         
453         so, the process procedure is :
454 @ ergodic catalog, and dispose strnode to varlist. ergodic current dir in dst-dir with varlist.
455 @ ergodic catalog varlist continously, because we want to keep the order of catanode as we can. so the default catanode generating
456 sequence is based on the original catalog varlist. 
457 @ compare catalog varnode with the one in current dir varlist, if there is a cataid in current dir varlist.
458 + output catanode string by current dir varnode in varlist. unset the varnode in catalog varlist.
459 + ergodic varnode in current dir of catalog varlist by current level cataid, and append catanode string by catalog varlist with 
460 '<->' cataid, and comment this row with '#'. it means it's the different catanode from dst-dir.
461 @ compare catalog varnode with the one in current dir varlist, if there is no cataid in current dir varlist.
462 + if there is no cataid neither in catalog varlist, nor in dst-dir varlist, use the count number in current dir instead.
463 + if the cataid is exist in catalog varlist, but not exist in dst-dir varlist, get the name of current catanode, get varnode in 
464 dst-dir varlist by this name string, then output catanode string by this varnode.
465 + if the cataid is not exist in catalog varlist, but exist in dst-dir varlist, output catanode string by dst-dir varlist.
467         delete varnode in catanode varlist after comparation. at the end of current dir ergodic, ergodic catanode varlist in current
468 dir by current level cataid. change cataid to '<->', and output this catanode string with '#' prefix.
471 # 8.itemnode
472 ============
473         every node is a formatted string with the corresponding physical-feature. eg: dirnode is a physical dir in file system, and 
474 a formatted dir name string.
475         itemnode is a spacial node in catalog. it associated with several files. the function item2var()/var2item() is to be implemented.
476 it invoke str2var()/var2str() in lower level. the work different from other node processing, is that it should associate itemnode
477 with serveral strnode, then it invoke str2var()/var2str() as a normal node.
479     <1>.[item].TestModule."program module for testing".[file:c-h-sh]
480     <2>.[item].TestModule."program module for testing".[c_src]
481     <3>.[item].TestModule."program module for testing".[test]
483         it need a list of file name to be generated. and the file name is generated by 'file-type' in catanode.
484         file-type string is consisted by two part:
485 @ type name
486 @ type file list. only 'file' has this paramter, and seperate type name with ':'
489 # 8.1.node type
490 ===============
491         type name is a tag string for a set of file with different surfix. the defination of this tag is in catalog file or imi 
492 paramter file it included.
493         it is defined in strsyntax section of an imi file, or redefined in a catalog file.
495 [strsyntax]
496 # Ã¿Ò»¸öfextÀàÐÍÓжÔÓ¦µÄimi²ÎÊýÐÅÏ¢¡£
497 # Ä¬ÈÏʹÓÃfileÀàÐÍ£¬¸ù¾Ý²ÎÊý´«µÝÀ©Õ¹Ãû×Ö·û´®£¬²¢×ª»»ÎªtypeÃû³ÆÁÐ±í¡£
498 #attr file::sfx='.c/.h/_test.c'
499 #attr file::typename='c/h/test_c'
501 # Áí°üº¬Ò»¸ösrcÀàÐÍ¡£ÓëfileÒ»Ñù¿ÉʹÓòÎÊýÁÐ±í¡£Êä³öÒ»¸ösrcÀàÐ͵Ätype£¬ÔÙ¸ù¾ÝÕâ¸ötype»ñÈ¡fextºÍ¶ÔÓ¦µÄtype
503 # fileÖ®ÍâµÄÆäËüÀàÐÍ£¬¸ù¾Ýsfx¶¨ÒåµÄÀ©Õ¹Ãû/surffixÁÐ±í£¬ÒÔ¼°¶ÔÓ¦µÄÀàÐÍÃû³ÆÁÐ±í¡£¸ù¾ÝÀàÐÍÃû³Æ£¬»ñÈ¡Ò»ÖÖÎļþÃûµÄ×Ö·û´®ÉèÖÃÐÅÏ¢¡£¸ù¾ÝÀàÐÍ
504 Ãû³Æ£¬Ê¹ÓöÔÓ¦µÄtmplÄ£°å¡£
505 # µ±typeÊôÐÔ䶨Òåʱ£¬Ê¹ÓÃsfxÊôÐÔµÄÖµ£¬²¢½«µÚÒ»¸ö.È¥µô£¬ÆäËü.Ìæ»»³É_¡£
506 attr src::sfx='.c/.h/_test.c'
507 attr src::typename='c/h/test_c'
508 attr shtest::sfx='.sh/.stdout'
509 attr shtest::typename='shtest/stdout'
510 attr module::sfx='.c/.h/.mdl/_test.c/.stdout'
511 attr module::typename='c/h/mdl/test_c/stdout'
514         src/test/module is defined as a type-name. it include attr of sfx(surfix) and type-tag. the attr of sfx is a list of file 
515 extension name seperated by '/', and type-tag is the corresponding type name used for file type defination attribute.
517 # shtest file name string
518 [shtest]
519 attr syntax::fmt='@{0}.@{2}.sh'
520 attr syntax::var_rege="([a-zA-Z0-9_ ]*)"
521 #attr syntax::regexpr=
522 attr syntax::sepchar='.'
523 attr syntax::attr_idx=( NID NNAME NFEXT )
524 attr syntax::nid_idx=0
527 # 8.2.var2item()
528 ================
529         strnode generate is a formatted string fill by varnode. the procedure of get_item_file_list() is :
530         
531 varnode => file-type => strsyntax::<file-type>::typename => typename-array => <typename> define => strfmt() => strnode => itemnode
533         get file file-type list of itemcata:
534 + default file-type is file, use ext-nane in paramter list
535 + src type, the same as file, use the pramter in 'src' attr var.
536 + user defined type, include file ext-name and tmpl type string in paramter.
539 # 8.3.item2var()
540 ================
541         translating itemnode to varnode is more complex. there are two steps of this function:
542 @ get item name list in current dir.
543 @ translate itemnode to varnode by item name.
545         there is not only one file associated with itemnode, so, itemnode can not be ergodiced one by one. use list_item_in_dir()
546 to get the item name list. the process procedure is like this:
548 strsyntax::inode::type =|
549 curr-dir => file-list  =|=> main item file list => varnode =|=> tmp-varlist => varnode |=> curr-dir-varlist
550                         dir-list => str2var => varnode                 =|                          |=> ... => varnode => curr-dir-varlist
552         it output a tmp-varlist, and generate dirnode if it is a dir object, and invoke item2var() if it is an item object.
553         the procedure of itemnode translateing to varnode is like this:
555        item-file-extname => <extname>::syntax::<attr> =| 
556              ^                                         |
557                      |--------------------------|              |
558 varnode => item-name => item-file-list =|=> item-file =|=> varnode-varlist => node_attr_combine() => varnode
560         get attr of itemnode:
561 + get catanode attr-var by 'name' of itemnode, use the type value to get ext-name list, 
562 + get the item file list by get_item_file_list_in_dir(), and get the ext-name list.
563 + compare two ext-name list if catanode type ext-name list exist.
564 + or use ext-name to get file name syntax attr-var, and check file name by it.
565 + if the file is not matching syntax get from  ext-name, use the surfix string after 'name', to get the ext-type attr-var. matching 
566 again, if matched, check if there are other file use the same ext-name. if no file found by this ext-name, delete this ext-name in 
567 list, insert surfix string instead.
568 + matching ext-name list with the type defined in itemnode type list. no file matching, use file:<ext-name-list> instead.
571 # 9.conclusion
572 ==============
573         there are some thing we need to pay attension on it.
574 @ 2 stage processing, dir and content.
575 @ 2 direction of processing, catalog to src code, and opersite.
576 @ pay attension on itemnode:
577 + the destination node is existing. ccomparesrc and dest varlist at the same time.
578 + multi file, list item in a dir at the same time, and can't be ergodiced one by one. use curr-dir varlist instead of dst-dir 
579 varlist.
580 + the cataid is existing in var node, use cataid from dst-dir/catanode/counter.
581 + there is a sequence of catanode in catalog file. the sequnce is decided by cataid in dst-dir, or catanode sequence, or count 
582 number in curr-dir.
583 @ get file type list of itemcata
584 + default type is file, use ext-nane in paramter list
585 + src type, the same as file, use the pramter in 'src' attr var.
586 + user defined type, include file ext-name and tmpl type string in paramter.
587 @ get file type attr of attr itemnode
588 + get catanode attr-var by 'name' of itemnode, use the type value to get ext-name list, 
589 + get the item file list, and get the ext-name list.
590 + compare two ext-name list if catanode type ext-name list exist.
591 + or use ext-name to get file name syntax attr-var, and check file name by it.
592 + if the file is not matching syntax get from  ext-name, use the surfix string after 'name', to get the ext-type attr-var. matching 
593 again, if matched, check if there are other file use the same ext-name. if no file found by this ext-name, delete this ext-name in 
594 list, insert surfix string instead.
595 + matching ext-name list with the type defined in itemnode type list. no file matching, use file:<ext-name-list> instead.
596 @ translation between strnode and varnode
597 + use strfmt to generate string.
598 + use seperated char to divide string into an array. uae idx to attr, store in corresponding attr var.
599 + use regexpr, output matching string.
600 + use node_fmt paramter that same as the one for strfmt. fill var regexpr string into node_fmt, it's the same as regexpr.
603 # Appendix. function list
604 =========================
606 # [attr.shlib]
607 # varlist_del()
608 # varlist_var_exist()
609 # varnode_in_list()
611 # varlist_foreach()
614 # [strsyntax.shlib]
615 # [strnode.shlib]
616 str2var()/var2str()
619 # [catadir.shlib]
620 # dir2var()/var2dir()
621 # item2var()/var2item()
623 # list_item_in_dir()
624 # node_attr_combine()
625 # get_item_file_list()
626 # get_item_file_list_in_dir()
628 # catadir_foreach()
629 # catadir_get_dir_varlist()
632 # [catalog.shlib]
633 # cata2var()/var2cata(),
635 # dstdir2catalog()/catalog2dstdir()
636 # filecont2catalog()/catalog2filecont()
638 # catalog_foreach()
639 # catalog_get_dir_varlist()
640 # catalog_get_cont_varlist()
643 # [c-lang.shlib]
644 # *cont2var()/*var2cont()
646 # content_foreach()
647 # content_get_cont_varlist()